package net.zjitc.config;

import net.zjitc.interceptor.MyInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author 毛若颖
 * @date 2024/12/17 14:55
 */
@Configuration
public class MvcConfig implements WebMvcConfigurer {
//    注册拦截器
    @Bean
    public  MyInterceptor myInterceptor(){
    return new MyInterceptor();
}
//    添加拦截器到spring mvc拦截器链
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
       registry.addInterceptor(myInterceptor()).addPathPatterns("/*");
    }
}
